<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>欢迎访问产品运营互动中心！</title>
		<script src="<s:url value="/script/jquery_last.js"/>" type="text/javascript"></script>
<script src="<s:url value="/script/formValidator.js"/>" type="text/javascript" charset="UTF-8"></script>
<script src="<s:url value="/script/formValidatorRegex.js"/>" type="text/javascript" charset="UTF-8"></script>
<script language="javascript" src="<s:url value="/script/DateTimeMask.js"/>" type="text/javascript"></script>
<script language="javascript" src="<s:url value="/script/ShowProcessBar.js"/>" type="text/javascript"></script>
<script type="text/javascript" src="<s:url value="/script/selfResize.js"/>"></script>
<link rel="stylesheet" href="<s:url value="/css/style_new.css"/>">
<link rel="stylesheet" href="<s:url value="/css/validator.css"/>">
<script>
function initLoad(){
	f_iframeResize();
}
window.onload = initLoad;
window.setInterval("initLoad()", 200);
</script>
		<script type="text/javascript" src="<s:url value="/script/selfResize.js"/>"></script>
		<script>
		function show(url){
			window.open(url);
		}
		function initLoad(){
			f_iframeResize();
		}
		window.onload = initLoad;
		$(document).ready(function(){
			$.formValidator.initConfig({autotip:true,onerror:function(msg){alert(msg)}});
			$("select[name='shareReference.referenceType.id']").formValidator({tipid:"referenceTypetip",onshow:"资料类型"}).inputValidator({onerror:"您还没有输入资料类型",empty:{leftempty:false,rightempty:false,emptyerror:"资料类型不能为空"}});
			$("input:text[name='shareReference.title']").formValidator({tipid:"titletip",onshow:"标题"}).inputValidator({min:1,onerror:"您还没有输入标题",empty:{leftempty:false,rightempty:false,emptyerror:"标题两边不能有空符号"}});
			$("textarea[name='shareReference.content']").formValidator({tipid:"contenttip",onshow:"内容"}).inputValidator({min:1,max:300,onerror:"您输入的描述长度不正确,请确认"});
			//$("input:text[name='shareReference.keyword']").formValidator({tipid:"keywordtip",onshow:"关键字"}).inputValidator({min:1,onerror:"您还没有输入资料关键字",empty:{leftempty:false,rightempty:false,emptyerror:"关键字两边不能有空符号"}});
		});
		</script>
	</head>

	<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
		<table width="980" border="0" cellspacing="0" cellpadding="0"
			align="center">
			<form action="business/share/listShareReference.action" method="post">
			<tr>
				<td>
					<table width="100%" border="0" cellpadding="0" cellspacing="0"
						background="<s:url value="/images/new/gxzl_index_2.gif"/>">
						<tr>
							<td width="20" height="32">
								&nbsp;
							</td>
							<td width="20">
								<img src="<s:url value="/images/new/dq_dot.gif"/>" width="15"
									height="12" />
							</td>
							<td>
								当前位置：<a
											href="<s:url value="/business/share/showAllShareReference.action"/>"><font
											color="#003399">共享资料</font></a>
							</td>
							<td width="60">
							</td>
							<td width="200">
							</td>
							<td width="100">
							</td>
						</tr>
					</table>
				</td>
			</tr>
			</form>

			<tr>
				<td background="" class="leftbg">
					<table width="90%" border="0" cellspacing="0" cellpadding="0"
						align="center" bgcolor="#FFFFFF">
						<tr>
							<td width="20%" valign="top">
								<table width="100%" height="400" border="0" cellspacing="0"
									cellpadding="0" align="center" bgcolor="#FFFFFF">
									<tr>
										<td valign="top" align="center">
											<br>
											<s:form action="saveShareRef.action" namespace="/security"
												method="post" enctype="multipart/form-data"
												onsubmit="return ($.formValidator.pageIsValid('1')&&setIsPublish());">
												<input type="hidden" name="shareReference.id" value="${shareReference.id}">
												<input type="hidden" name="shareReference.procinstId" value="${shareReference.procinstId}">
												<input type="hidden" name="shareReference.reqCode" value="${shareReference.reqCode}">
												<input type="hidden" name="refType" value="${refType}" />
												<table width=98% border="0" cellspacing="0" cellpadding="0">
													<tr>
														<td height="5">
															<table width="100%" border="0" cellspacing="0" cellpadding="0">
																<tr>
																	<td width="5" height="5"><img src="<s:url value="/images/cphdzx_tab1.gif"/>" width="5" height="5" /></td>
																	<td class="tdborderup"><img src="<s:url value="/images/spacer.gif"/>" width="1" height="1" /></td>
																	<td width="5"><img src="<s:url value="/images/cphdzx_tab2.gif"/>" width="5" height="5" /></td>
																</tr>
															</table>
														</td>
													</tr>
													<tr>
														<td  class="tdborderleftright">
															<TABLE width="98%" cellSpacing=1 cellPadding=0
																align="center">
																<TR height=30>
																	<TD align=left width="10%">
																		<input type="submit" id="Submit" name="Submit" value="保 存">
																		<input type="button" value="返 回"
																			onClick="location.href='<s:url value="/business/share/shareReference.action"/>'">
																	</TD>
																</TR>
															</table>
															<s:if test="#returnMsg==null">
															</s:if>
															<s:else>
																<TABLE width="98%" cellSpacing=1 cellPadding=0
																	align="center">
																	<TR height=30>
																		<TD align=left width="10%">
																			<font color="red">${returnMsg}</font>
																		</TD>
																	</TR>
																</table>
															</s:else>
															<table width="98%" border="0" cellspacing="0"
																cellpadding="7" align="center" class=tablecolor2>
																<tr>
																	<td width="19%" bgcolor="D6E3FA">
																		<div align="right">
																			<font color="red">*</font>资料类型：
																		</div>
																	</td>
																	<td width="81%">
																		<s:select name="shareReference.referenceType.id"
																			list="lRefType" listKey="id" listValue="name"
																			theme="css_xhtml" />
																		<div id="referenceTypetip" style="width:auto"></div>
																	</td>
																</tr>
																<tr>
																	<td width="19%" bgcolor="D6E3FA">
																		<div align="right">
																			<font color="red">*</font>标&nbsp;&nbsp;&nbsp;&nbsp;题：
																		</div>
																	</td>
																	<td width="81%">
																		<s:textfield name="shareReference.title"
																			theme="css_xhtml" size="64" />
																		<div id="titletip" style="width:auto"></div>
																	</td>
																</tr>
																<tr>
																	<td width="19%" bgcolor="D6E3FA">
																		<div align="right">
																			内&nbsp;&nbsp;&nbsp;&nbsp;容：
																		</div>
																	</td>
																	<td width="81%">
																		<s:textarea name="shareReference.content"
																			theme="css_xhtml" cols="50" rows="6" />
																		<div id="contenttip" style="width:auto"></div>
																	</td>
																</tr>
																<tr>
																	<td width="19%" bgcolor="D6E3FA">
																		<div align="right" class="STYLE2">
																			附&nbsp;&nbsp;&nbsp;&nbsp;件：
																		</div>
																	</td>
																	<td width="81%">
																		<table width="100%" border="0" class=tablecolor2>
																			<tr>
																				<td width="" align="center" bgcolor="D6E3FA">
																					附件名称
																				</td>
																				<td width="50" align="center" bgcolor="D6E3FA">
																					是否发布
																				</td>
																				<td width="50" align="center" bgcolor="D6E3FA">
																					删除
																				</td>
																			</tr>
																			<s:iterator id="attach" value="attachs">
																				<input type="hidden" name="attachIDs"
																					value="<s:property value="id" />" />
																				<tr>
																					<td>
																						<s:if test="isFtp != 1">
																							<a href="<s:url value="/common/showFile.action?attach.id="/><s:property value="id" />"
																								target="_blank">
																								<s:property value="fullName" />
																							</a>
																						</s:if>
																						<s:if test="isFtp == 1">
																							<a href="<s:url value="/common/showFtpFile.action?attach.id="/><s:property value="id" />"
																								target="_blank">
																								<s:property value="fullName" />
																							</a>
																						</s:if>
																					</td>
																					<td align="center">
																						<input type="checkbox" name="publishIDs"
																							value="<s:property value="id" />"
																							<s:if test="isPublish==1">checked</s:if>>
																					</td>
																					<td align="center">
																						<input type="checkbox" name="delIDs"
																							value="<s:property value="id" />">
																					</td>
																				</tr>
																			</s:iterator>
																		</table>
																		<br />
																		<table width="100%" border="0" class=tablecolor2>
																			<tr>
																				<td width="" colspan="2" align="left"
																					bgcolor="D6E3FA">
																					附件上传
																				</td>
																			</tr>
																			<tr>
																				<td width="10px"></td>
																				<td align="left">
																					<input type="file" name="upload" size="40"/> <br/>													
																					发布
																					<input type="radio" name="cbIsPublish1" value="1" checked>
																					不发布
																					<input type="radio" name="cbIsPublish1" value="2" >
																					<input type="hidden" name="isPublishs" value="0"/>
																					<input type="hidden" name="isFtp" value="2"/>
																					<input type="hidden" name="ftpFile" value=""/>
																				</td>
																			</tr>
																			<tr>
																				<td>&nbsp;</td>
																				<td>
																					<input type="file" name="upload" size="40"/> <br/>
																					发布
																					<input type="radio" name="cbIsPublish2" value="1" checked>
																					不发布
																					<input type="radio" name="cbIsPublish2" value="2" >
																					<input type="hidden" name="isPublishs" value="0"/>
																					<input type="hidden" name="isFtp" value="2"/>
																					<input type="hidden" name="ftpFile" value=""/>
																				</td>
																			</tr>
																			<tr>
																				<td>&nbsp;</td>
																				<td>
																					<input type="file" name="upload" size="40"/> <br/>
																					发布
																					<input type="radio" name="cbIsPublish3" value="1" checked>
																					不发布
																					<input type="radio" name="cbIsPublish3" value="2" >
																					<input type="hidden" name="isPublishs" value="0"/>
																					<input type="hidden" name="isFtp" value="2"/>
																					<input type="hidden" name="ftpFile" value=""/>
																					 
																				</td>
																			</tr>
																		</table>
																	</td>
																</tr>
																<tr>
																	<td width="19%" bgcolor="D6E3FA">
																		<div align="right">
																			发布经理：
																		</div>
																	</td>
																	<td width="81%">
																		<input type="text" id="shareReference.creator"
																			name="shareReference.creator" readonly
																			value="${shareReference.creator}">
																		<input type="button" name="selType" value="选择人员"
																			onClick="selectMainPerson()" />
																	</td>
																</tr>
																<tr>
																	<td width="19%" bgcolor="D6E3FA">
																		<div align="right">
																			密&nbsp;&nbsp;&nbsp;级：
																		</div>
																	</td>
																	<td width="81%">
																		<s:select name="shareReference.secret"
																			list="lSecretType" listKey="id" listValue="name"
																			theme="css_xhtml" />
																	</td>
																</tr>
																<tr style="display:none;">
																	<td width="19%" bgcolor="D6E3FA">
																		<div align="right">
																			<font color="red">*</font>关&nbsp;键&nbsp;字：
																		</div>
																	</td>
																	<td width="81%">
																		<s:textfield name="shareReference.keyword"
																			theme="css_xhtml" />
																	</td>
																</tr>
                                                                
																<input type="hidden" name="shareReference.begin"
																	value="<s:date name="shareReference.begin" format="yyyy-MM-dd HH:mm:ss"/>">
																<input type="hidden" name="shareReference.end"
																	value="<s:date name="shareReference.end" format="yyyy-MM-dd HH:mm:ss"/>">
															</table>
														</td>
													</tr>
													<tr>
														<td height="5">
															<table width="100%" border="0" cellspacing="0" cellpadding="0">
																<tr>
																	<td width="5" height="5"><img src="<s:url value="/images/cphdzx_tab3.gif"/>" width="5" height="5" /></td>
																	<td class="tdborderbottom"><img src="<s:url value="/images/spacer.gif"/>" width="1" height="1" /></td>
																	<td width="5"><img src="<s:url value="/images/cphdzx_tab4.gif"/>" width="5" height="5" /></td>
																</tr>
															</table>
														</td>
													</tr>
												</table>
										</td>
									</tr>
								</table>
								</s:form>
	</body>
</html>


<script>

//新增附件是否发布       单选处理 0 无附件   1 有附件 发布  2 有附件不发布

	function setIsPublish(){
	
		var isPublishs = document.getElementsByName("isPublishs");
		var cbIsPublishs1 = document.getElementsByName("cbIsPublish1");
		var cbIsPublishs2 = document.getElementsByName("cbIsPublish2");
		var cbIsPublishs3 = document.getElementsByName("cbIsPublish3");
		var uploads = document.getElementsByName("upload");
		
		
		for(i = 0; i < cbIsPublishs1.length; i++){
			if(cbIsPublishs1[i].checked == true){
		  		if(cbIsPublishs1[i].value == 1 && (uploads[0].value != null && uploads[0].value != "")){
		   			isPublishs[0].value = 1; 
		   		} else if (cbIsPublishs1[i].value == 2 && (uploads[0].value != null && uploads[0].value != "")){
		   			isPublishs[0].value = 2;
			   	} else {
			   		isPublishs[0].value = 0;
			   	}
  			}
  		}		   	
  		
		for(i = 0; i < cbIsPublishs2.length; i++){
		  	if(cbIsPublishs2[i].checked == true){
		   		if(cbIsPublishs2[i].value == 1 && (uploads[1].value != null && uploads[1].value != "")){
		   			isPublishs[1].value = 1;
		   	  	} else if (cbIsPublishs2[i].value == 2 && (uploads[1].value != null && uploads[1].value != "")){
		   			isPublishs[1].value = 2;
		   		} else {
			   		isPublishs[1].value = 0;
			   	}		   		
 			}
  		}		   		
		for(i = 0; i<cbIsPublishs3.length; i++){
			if(cbIsPublishs3[i].checked == true){
			   	if(cbIsPublishs3[i].value == 1 && (uploads[2].value != null && uploads[2].value != "")){
			   		isPublishs[2].value = 1;
		   	  	} else if (cbIsPublishs3[i].value == 2 && (uploads[2].value != null && uploads[2].value != "")){
		   			isPublishs[2].value = 2;
		   	  	} else {
			   		isPublishs[2].value = 0;
			   	}	   	  
  			}
  		}
		if(!uploadValidator()){
			return false;
		}
		b_setDisable(document.getElementById("Submit"));
		return true;
		
	}

		//验证是否ftp上传
		function uploadValidator()
		{
			var uploads = document.getElementsByName("upload");
			var isFtps = document.getElementsByName("isFtp");
			var ftpFiles = document.getElementsByName("ftpFile");
//限制大小	以上用ftp		
			var maxFileSize = parseInt("${ftpMaxSize}"); 
			//限制最大100M
			var maxSize = 100*1024*1024;
			try{
				for(i=0;i<uploads.length;i++){
		   		if(uploads[i].value != null && uploads[i].value != ""){
		   			
						var image = new Image();
						image.dynsrc = uploads[i].value;
						if(image.fileSize > maxFileSize)
						{
							isFtps[i].value = "1";
							var n = i + 1;
							if(image.fileSize > maxSize)
							{
								alert("单个附件不能超过100M！");
								return false;
							}
							//alert("dynsrc您输入的第"+n+"个附件大小大于10M！请使用ftp上传！");
							ftpFiles[i].value = uploads[i].value;
						}
						else
						{
						isFtps[i].value = "0";
						}
		   		}		   		
			 }
			}catch(e)
			{
				for(i=0;i<uploads.length;i++){
		   		if(uploads[i].value != null && uploads[i].value != ""){
		   			//isFtps[i].value = "0";
					//alert("ActiveXObject"+uploads[i].value);1;//
					var fileSize = getFileSize(uploads[i].value);
					//alert("fileSize="+fileSize);
					if(fileSize > maxFileSize)
					{
						isFtps[i].value = "1";
						var n = i + 1;
						if(fileSize > maxSize)//image.
						{
							alert("单个附件不能超过100M！");
							return false;
						}
						//alert("dynsrc您输入的第"+n+"个附件大小大于10M！请使用ftp上传！");
						ftpFiles[i].value = uploads[i].value;
						//alert(ftpFiles[i].value+"=ftpFiles["+i+"].value");
					}
				}
				}
			}
			return true;
		}

function getFileSize (fileName) {   
  if (document.layers) {   
  alert('document.layers');
    if (navigator.javaEnabled()) {   
      var file = new java.io.File(fileName);   
      if (location.protocol.toLowerCase() != 'file:')   
        netscape.security.PrivilegeManager.enablePrivilege(   
        'UniversalFileRead'   
        );   
      return file.length();   
    }   
    else return -1;   
  }   
  else if (document.all) {  
  //alert('document.all');		 
    window.oldOnError = window.onerror;   
    window.onerror = function (err) {   
      if (err.indexOf('utomation') != -1) {   
       // alert('没有访问文件的权限');   
    //alert("file.Size0");
        return true;   
      }   
      else   
        return false;   
    };   
    //alert("file.Size1");
    var fso = new ActiveXObject('Scripting.FileSystemObject');
    //alert("file.Size2");   
    var file = fso.GetFile(fileName);   
    //alert("file.Size3");
    window.onerror = window.oldOnError;   
   // alert("file.Size4");
    return file.Size;   
  }   
}   

</script>

<script>

<!--
	function uploadFile(id) {
		window
				.open(
						'<s:url value="/common/uploadFile.action?attach.refEntity=PRODUCTREFERENCE&attach.refEntityID="/>'
								+ id, "uploadfile",
						"dialogWidth=420px;dialogHeight=300px");
	}
	
	function addComponent()
	{
		var uploadHTML=document.createElement("<input type='file'　name='upload'/>");
		document.getElementById("files").appendChild(uploadHTML);
		uploadHTML=document.createElement("<p/>");
		document.getElementById("files").appendChild(uploadHTML);
	}
	
function selectMainPerson(){
    var url="<s:url value='/' escapeAmp='false'/>"+"organ/toOrganTree.action?type=&path=toPersonTree&module=radio&date=<%=System.currentTimeMillis()%>";	 
    var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:650px;dialogHeight:600px;scroll:yes;");
	 if(returnData){
	 	document.all["shareReference.creator"].value=returnData[1];
	 }
}
-->
</script>
